package com.woniuxy.rms.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.rms.advice.LogPoint;
import com.woniuxy.rms.pojo.Logs;
import com.woniuxy.rms.service.LogService;
import com.woniuxy.rms.util.DataResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/**
 * Auther: ChenGang  <br/>
 * Date: 2020/3/28 0028:下午 4:03  <br/>
 * Description:日志控制层
 */
@Controller
@RequestMapping("/log")
public class LogController {

    @Autowired
    LogService logService;
    /**
     * Description : 日志列表  <br/>
     * ChangeLog : 1. 创建 (2020/3/28 0028 下午 12:38 [Administrator]);
     * @param currentPage 当前页
     * @param pageSize 页大小
     * @return com.woniuxy.rms.util.DataResult
     */
    @GetMapping("/list")
    @ResponseBody
    @LogPoint("日志列表查询")
    @RequiresPermissions("log:select")
    public DataResult logList(@RequestParam(defaultValue = "1",required = false,name = "page") Integer currentPage,
                              @RequestParam(defaultValue = "10",required = false,name = "limit") Integer pageSize,
                              @RequestParam(required = false,name = "operate") String operate,
                              @RequestParam(required = false,name = "begin") Date begin,
                              @RequestParam(required = false,name = "end") Date end,
                              @RequestParam(required = false) String role){
        List<Logs> logs = logService.findByPage(currentPage,pageSize,operate,begin,end,role);
        PageInfo info = new PageInfo(logs);
        return DataResult.success(info);
    }
}